/*
 * Copyright (C) 2022 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef LAUNCHERITEMHELPER_H
#define LAUNCHERITEMHELPER_H

#include <QString>
#include <tuple>
#include "modeldefs.h"

class LauncherItem;
namespace UKUI {
class BaseItem;
class IconItem;
class GroupItem;
class ContainerItem;
class Widget;
}
class LauncherItemHelper 
{
public:
    static LauncherItem *createAppIconLauncherItem(const UKUI::IconItem *iconItem, int page);

    static std::tuple<LauncherItem *, model::MultiPageModel *> 
                createAppGroupLauncherItem(const UKUI::GroupItem *groupItem, 
                                           const QList<QList<UKUI::IconItem *>> &childrenItem, 
                                           int page);

    static std::tuple<LauncherItem *, model::MultiPageModel *> 
                createAppContainerLauncherItem(const UKUI::ContainerItem *containerItem,
                                               const QList<QList<UKUI::IconItem *>> &childrenItem, 
                                               int page);
    
    static LauncherItem *createAddIconItem(int page, int state = LauncherItem::Normal);
    static LauncherItem *createWidgetItem(const UKUI::Widget *widgetItem, int page);

private:
    static LauncherItem *createBaseLauncherItem(const UKUI::BaseItem *baseItem, int page);
    static UKUI::GroupItem *containerItem2GroupItem(const UKUI::ContainerItem *containerItem);
    static bool existsInWhiteList(const QString &desktopFileName);
};

#endif
